//============================================================================================
/**
 * @file	numsel_sublcd.c
 * @brief	下画面数値入力処理
 * @author	Hiroyuki Nakamura
 * @date	09.03.03
 */
//============================================================================================
#include "common.h"

#include "system/lib_pack.h"
#include "system/fontproc.h"
#include "system/cursor_move.h"
#include "system/snd_tool.h"
#include "field/field.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_fieldmenu.h"

#include "../field_poketch.h"

#include "numsel_sublcd.h"
#include "numsel_snd_def.h"

#include "../../application/wifi_b_tower/btower_codein.naix"



//============================================================================================
//	定数定義
//============================================================================================

#define HEAPID_SUBLCD_MENU	( HEAPID_POKETCH_APP )		// ヒープＩＤ

#define	NS_SUB_ACTOR_DISTANCE 	( 256 * FX32_ONE )		// Ｙ座標オフセット
#define NS_RES_TYPE_MAX			( 4 )					// リソースタイプ数
#define	NS_RES_ID				( 921 )					// リソースＩＤ

//#define	FIX_TOUCH_TBL_MAX	( 10 + 3 + 1 )				// 数字＋ボタン＋終端
//#define	TOUCH_TBL_MAX		( 6 + FIX_TOUCH_TBL_MAX )	// ６桁＋数字＋ボタン＋終端

#define	DEFAULT_KETA	( 6 )
//#define	DEFAULT_MAX		( 999999 )
#define	DEFAULT_MAX		( 9999 )

enum {
	MAINSEQ_MAIN = 0,
	MAINSEQ_BUTTON_ANM,
	MAINSEQ_END
};

enum {
	BTN_ANM_MODE_OBJ = 0,
	BTN_ANM_MODE_BG
};

// RES ID
enum {
	NS_RES_ID_BUTTON = NS_RES_ID,
	NS_RES_ID_NUM,
};

// RES MAN ID
enum {
	NS_RES_MAN_BUTTON = 0,
	NS_RES_MAN_NUM,

	NS_RES_MAN_MAX,
};

// OBJ ID
enum {
	NS_OBJ_CURSOR = 0,
	NS_OBJ_NUM_BAR,
	NS_OBJ_RET_BUTTON,
	NS_OBJ_ENTER_BUTTON,
	NS_OBJ_CANCEL_BUTTON,
	NS_OBJ_NUM0,
	NS_OBJ_NUM1,
	NS_OBJ_NUM2,
	NS_OBJ_NUM3,
	NS_OBJ_NUM4,
	NS_OBJ_NUM5,
	NS_OBJ_MAX
};

// BMPWIN ID
enum {
	NS_BMP_RET = 0,
	NS_BMP_ENTER,
	NS_BMP_CANCEL,
	NS_BMP_MAX
};

typedef struct {
	u8	btn_mode:1;
	u8	btn_id:7;			// OBJ = ID, BG = FRM
	u8	btn_pal1;
	u8	btn_pal2;
	u8	btn_seq:3;
	u8	btn_cnt:5;

	u8	btn_px;			// BGのみ
	u8	btn_py;
	u8	btn_sx;
	u8	btn_sy;
}BUTTON_ANM_WORK;

typedef struct {
	// フィールドから渡されるもの
	GF_BGL_INI * bgl;
	u16 * sp_trg;
	FIELDSYS_WORK * fsys;
	void * scr_wk;

	NUMSEL_PARAM * prm;

	TCB_PTR	tcb;	// 本体のポインタ

	// セルアクター
	CLACT_SET_PTR 			claSet;								// セルアクターセット
	CLACT_U_EASYRENDER_DATA	rndDat;								// 簡易レンダーデータ
	CLACT_U_RES_MANAGER_PTR	resMan[NS_RES_TYPE_MAX];			// リソースマネージャ
	CLACT_U_RES_OBJ_PTR 	resObj[NS_RES_MAN_MAX][NS_RES_TYPE_MAX];		// リソースオブジェテーブル
	CLACT_WORK_PTR			actWork[NS_OBJ_MAX];			// セルアクターワークポインタ配列

	GF_BGL_BMPWIN	win[NS_BMP_MAX];	// BMPWIN

	CURSOR_MOVE_WORK * cmwk;	// カーソル移動ワーク

	BUTTON_ANM_WORK	bawk;

	u32	input_num[DEFAULT_KETA];
	s32	input_pos;

	u16	main_seq;
	u16	next_seq;

	u32	keta;		// 入力桁数
	u32	num;

}NUMSEL_WORK;

//static u32 testRet = 0;


// BMPWIN
//「もどる」
#define	BMPWIN_RET_FRM		( GF_BGL_FRAME0_S )
#define	BMPWIN_RET_PX		( 1 )
#define	BMPWIN_RET_PY		( 21 )
#define	BMPWIN_RET_SX		( 8 )
#define	BMPWIN_RET_SY		( 2 )
#define	BMPWIN_RET_PAL		( 0 )
#define	BMPWIN_RET_CGX		( 1 )
//「けってい」
#define	BMPWIN_ENTER_FRM	( GF_BGL_FRAME0_S )
#define	BMPWIN_ENTER_PX		( 12 )
#define	BMPWIN_ENTER_PY		( 21 )
#define	BMPWIN_ENTER_SX		( 8 )
#define	BMPWIN_ENTER_SY		( 2 )
#define	BMPWIN_ENTER_PAL	( 0 )
#define	BMPWIN_ENTER_CGX	( BMPWIN_RET_CGX + BMPWIN_RET_SX * BMPWIN_RET_SY )
//「やめる」
#define	BMPWIN_CANCEL_FRM	( GF_BGL_FRAME0_S )
#define	BMPWIN_CANCEL_PX	( 23 )
#define	BMPWIN_CANCEL_PY	( 21 )
#define	BMPWIN_CANCEL_SX	( 8 )
#define	BMPWIN_CANCEL_SY	( 2 )
#define	BMPWIN_CANCEL_PAL	( 0 )
#define	BMPWIN_CANCEL_CGX	( BMPWIN_ENTER_CGX + BMPWIN_ENTER_SX * BMPWIN_ENTER_SY )


//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static void VramInit(void);
static void BgInit( GF_BGL_INI * bgl );
static void BgExit( GF_BGL_INI * bgl );
static void BgGraLoad( NUMSEL_WORK * wk, ARCHANDLE * ah );
static void BmpInit( NUMSEL_WORK * wk );
static void BmpExit( NUMSEL_WORK * wk );
static void ObjInit( NUMSEL_WORK * wk, ARCHANDLE * ah );
static void ObjExit( NUMSEL_WORK * wk );
static void ClaResManInit( NUMSEL_WORK * wk );
static void ClaResManExit( NUMSEL_WORK * wk );
static void ClaAdd( NUMSEL_WORK * wk, ARCHANDLE * ah );
static void ClaDel( NUMSEL_WORK * wk );
static void CursorMoveInit( NUMSEL_WORK * wk );
static void CursorMoveExit( NUMSEL_WORK * wk );
static void CursorMoveCallBack_On( void * work, int now_pos, int old_pos );
//static void CursorMoveCallBack_Off( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos );
//static void CursorMoveCallBack_Touch( void * work, int now_pos, int old_pos );
static void InputNumPut( NUMSEL_WORK * wk );

static void MainTask( TCB_PTR tcb, void * work );


//============================================================================================
//	グローバル変数
//============================================================================================

// BMPWIN
static const BMPWIN_DAT BmpWinData[] =
{
	{	//「もどる」
		BMPWIN_RET_FRM, BMPWIN_RET_PX, BMPWIN_RET_PY,
		BMPWIN_RET_SX, BMPWIN_RET_SY, BMPWIN_RET_PAL, BMPWIN_RET_CGX
	},
	{	//「けってい」
		BMPWIN_ENTER_FRM, BMPWIN_ENTER_PX, BMPWIN_ENTER_PY,
		BMPWIN_ENTER_SX, BMPWIN_ENTER_SY, BMPWIN_ENTER_PAL, BMPWIN_ENTER_CGX
	},
	{	//「やめる」
		BMPWIN_CANCEL_FRM, BMPWIN_CANCEL_PX, BMPWIN_CANCEL_PY,
		BMPWIN_CANCEL_SX, BMPWIN_CANCEL_SY, BMPWIN_CANCEL_PAL, BMPWIN_CANCEL_CGX
	},
};


//--------------------------------------------------------------------------------------------
/**
 * 初期化
 *
 * @param	bgl
 * @param	sub_panel_trg
 * @param	fsys
 * @param	work
 *
 * @return	TCB_PTR
 */
//--------------------------------------------------------------------------------------------
TCB_PTR NumSelSublcdInit(
			GF_BGL_INI * bgl, u16 * sub_panel_trg, FIELDSYS_WORK * fsys, void * work )
{
	TCB_PTR	tcb;
	NUMSEL_WORK * wk;
	ARCHANDLE * ah;
	u32	num;
	u32	i;

	// 異様にデカいがポケッチの合計と同じにしておく
	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_SUBLCD_MENU,  0x18000 );

	G2S_BlendNone();

	tcb = PMDS_taskAdd( MainTask, sizeof(NUMSEL_WORK), 10, HEAPID_SUBLCD_MENU );
	wk  = TCB_GetWork( tcb );

	wk->bgl    = bgl;
	wk->sp_trg = sub_panel_trg;
	wk->fsys   = fsys;
	wk->scr_wk = work;
	wk->tcb    = tcb;
	wk->prm    = work;

	wk->prm->num = NUMSEL_SUBLCD_RET_NONE;	// 入力場所初期化

	num = 100000;
	wk->keta = 0;
	for( i=0; i<DEFAULT_KETA; i++ ){
		if( wk->prm->max >= num ){
			wk->keta = 6-i;
			break;
		}
		num /= 10;
	}
	if( wk->keta == 0 ){
		wk->keta = 1;
	}

	ah = ArchiveDataHandleOpen( ARC_BTOWER_CODEIN, HEAPID_SUBLCD_MENU );

	VramInit();
	BgInit( bgl );
	BgGraLoad( wk, ah );
//	MsgInit( wk );
	BmpInit( wk );
	ObjInit( wk, ah );
	CursorMoveInit( wk );

	ArchiveDataHandleClose( ah );

	return tcb;
}

//--------------------------------------------------------------------------------------------
/**
 * 終了リクエスト
 *
 * @param	bgl		GF_BGL_INI
 * @param	tcb		TCB_PTR
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void NumSelSublcdQuitReq( GF_BGL_INI * bgl,  TCB_PTR tcb )
{
	NUMSEL_WORK * wk = TCB_GetWork( tcb );

	CursorMoveExit( wk );
	ObjExit( wk );
	BmpExit( wk );
//	MsgExit( wk );
	BgExit( wk->bgl );

	// タスク消去
	PMDS_taskDel( tcb );

	sys_DeleteHeap( HEAPID_SUBLCD_MENU );
}

//--------------------------------------------------------------------------------------------
/**
 * 終了待ち
 *
 * @param	bgl		GF_BGL_INI
 *
 * @retval	"TRUE = 終了"
 * @retval	"FALSE = それ以外"
 */
//--------------------------------------------------------------------------------------------
BOOL NumSelSublcdQuitWait( GF_BGL_INI * bgl )
{
	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * VRAM初期化
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void VramInit(void)
{
	GX_SetBankForSubBG( GX_VRAM_SUB_BG_32_H );
	GX_SetBankForSubOBJ( GX_VRAM_SUB_OBJ_16_I );
	GXS_SetOBJVRamModeChar( GX_OBJVRAMMODE_CHAR_1D_32K );
}

//--------------------------------------------------------------------------------------------
/**
 * BG初期化
 *
 * @param	bgl		GF_BGL_INI
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgInit( GF_BGL_INI * bgl )
{
	GXS_SetGraphicsMode( GX_BGMODE_0 );

	{
		GF_BGL_BGCNT_HEADER head = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0x7800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			0, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME0_S, &head, GF_BGL_MODE_TEXT );
		GF_BGL_ClearCharSet( GF_BGL_FRAME0_S, 32, 0, HEAPID_SUBLCD_MENU );
		GF_BGL_ScrClear( bgl, GF_BGL_FRAME0_S );
	}
	{
		GF_BGL_BGCNT_HEADER head = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0x7000, GX_BG_CHARBASE_0x04000, GX_BG_EXTPLTT_01,
			1, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME1_S, &head, GF_BGL_MODE_TEXT );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * BG解放
 *
 * @param	bgl		GF_BGL_INI
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgExit( GF_BGL_INI * bgl )
{
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME1_S );
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME0_S );
}

//--------------------------------------------------------------------------------------------
/**
 * BGグラフィックロード
 *
 * @param	wk		数値入力画面ワーク
 * @param	ah		アークハンドル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgGraLoad( NUMSEL_WORK * wk, ARCHANDLE * ah )
{
	ArcUtil_HDL_BgCharSet(
		ah, NARC_btower_codein_code_bg_ncgr,
		wk->bgl, GF_BGL_FRAME1_S, 0, 0, FALSE, HEAPID_SUBLCD_MENU );
	ArcUtil_HDL_ScrnSet(
		ah, NARC_btower_codein_code_bg_nscr,
		wk->bgl, GF_BGL_FRAME1_S, 0, 0, FALSE, HEAPID_SUBLCD_MENU );
	ArcUtil_HDL_PalSet(
		ah, NARC_btower_codein_code_bg_nclr, PALTYPE_SUB_BG, 0, 0, HEAPID_SUBLCD_MENU );
}

//--------------------------------------------------------------------------------------------
/**
 * BMP初期化
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BmpInit( NUMSEL_WORK * wk )
{
	MSGDATA_MANAGER * mman;
	STRBUF * str;
	u16	px;
	u16	i;

	mman = MSGMAN_Create( MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_fieldmenu_dat, HEAPID_SUBLCD_MENU );

	// タッチフォント読み込み
	FontProc_LoadFont( FONT_TOUCH, HEAPID_SUBLCD_MENU );

	for( i=0; i<NS_BMP_MAX; i++ ){
		GF_BGL_BmpWinAddEx( wk->bgl, &wk->win[i], &BmpWinData[i] );
		GF_BGL_BmpWinDataFill( &wk->win[i], 0 );
		str = MSGMAN_AllocString( mman, msg_menu_24+i );
		px  = GF_BGL_BmpWinGet_SizeX( &wk->win[i] ) * 8 / 2;
		px -= ( FontProc_GetPrintStrWidth( FONT_TOUCH, str, 0 ) / 2 );
		GF_STR_PrintColor(
			&wk->win[i], FONT_TOUCH, str, px, 0,
			MSG_NO_PUT, GF_PRINTCOLOR_MAKE(15,14,0), NULL );
		STRBUF_Delete( str );
		GF_BGL_BmpWinCgxOn( &wk->win[i] );
		GF_BGL_BmpWinOnVReq( &wk->win[i] );
	}

	FontProc_UnloadFont( FONT_TOUCH );

	MSGMAN_Delete( mman );
}

//--------------------------------------------------------------------------------------------
/**
 * BMP解放
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BmpExit( NUMSEL_WORK * wk )
{
	u32	i;

	for( i=0; i<NS_BMP_MAX; i++ ){
		GF_BGL_BmpWinDel( &wk->win[i] );
	}
}



//--------------------------------------------------------------------------------------------
/**
 * OBJ初期化
 *
 * @param	wk		数値入力画面ワーク
 * @param	ah		アークハンドル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjInit( NUMSEL_WORK * wk, ARCHANDLE * ah )
{
	// セルアクター初期化
	wk->claSet = CLACT_U_SetEasyInit( NS_OBJ_MAX, &wk->rndDat, HEAPID_SUBLCD_MENU );

	CLACT_U_SetSubSurfaceMatrix( &wk->rndDat, 0, NS_SUB_ACTOR_DISTANCE );

	ClaResManInit( wk );

	ClaAdd( wk, ah );
	InputNumPut( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ解放
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjExit( NUMSEL_WORK * wk )
{
	ClaDel( wk );

	ClaResManExit( wk );
	CLACT_DestSet( wk->claSet );
}

//--------------------------------------------------------------------------------------------
/**
 * リソースマネージャー初期化
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaResManInit( NUMSEL_WORK * wk )
{
	u32	i;

	for( i=0; i<NS_RES_TYPE_MAX; i++ ){
		wk->resMan[i] = CLACT_U_ResManagerInit( NS_RES_MAN_MAX, i, HEAPID_SUBLCD_MENU );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * リソースマネージャ削除
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaResManExit( NUMSEL_WORK * wk )
{
	u32	i;

	for( i=0; i<NS_RES_TYPE_MAX; i++ ){
		CLACT_U_ResManagerDelete( wk->resMan[i] );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * リソース読み込み
 *
 * @param	res_obj			リソースオブジェ
 * @param	res_man			リソースマネージャ
 * @param	ah				アークハンドル
 * @param	chr				キャラクタデータインデックス
 * @param	pal				パレットデータインデックス
 * @param	cel				セルデータインデックス
 * @param	anm				セルアニメインデックス
 * @param	pal_max			パレット数
 * @param	comm_res_chr	キャラリソースＩＤ
 * @param	comm_res_pal	パレットリソースＩＤ
 * @param	comm_res_cel	セルリソースＩＤ
 * @param	comm_res_anm	アニメリソースＩＤ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaResLoadHandle(
				CLACT_U_RES_OBJ_PTR * res_obj,
				CLACT_U_RES_MANAGER_PTR * res_man,
				ARCHANDLE * ah,
				int chr,
				int pal,
				int cel,
				int anm,
				int pal_max,
				int comm_res_chr,
				int comm_res_pal,
				int comm_res_cel,
				int comm_res_anm )
{
	// キャラクタデータ読み込み
	res_obj[CLACT_U_CHAR_RES] = CLACT_U_ResManagerResAddArcChar_ArcHandle(
									res_man[CLACT_U_CHAR_RES],
									ah,
									chr,
									FALSE,
									comm_res_chr,
									NNS_G2D_VRAM_TYPE_2DSUB,
									HEAPID_SUBLCD_MENU );

	// 転送
	CLACT_U_CharManagerSetAreaCont( res_obj[CLACT_U_CHAR_RES] );
	// グラフィックデータだけ破棄
	CLACT_U_ResManagerResOnlyDelete( res_obj[CLACT_U_CHAR_RES] );

	// パレットデータ読み込み
	res_obj[CLACT_U_PLTT_RES] = CLACT_U_ResManagerResAddArcPltt_ArcHandle(
									res_man[CLACT_U_PLTT_RES],
									ah,
									pal,
									FALSE,
									comm_res_pal,
									NNS_G2D_VRAM_TYPE_2DSUB,
									pal_max,
									HEAPID_SUBLCD_MENU );
	// 転送
	CLACT_U_PlttManagerSetCleanArea( res_obj[CLACT_U_PLTT_RES] );
	// グラフィックデータだけ破棄
	CLACT_U_ResManagerResOnlyDelete( res_obj[CLACT_U_PLTT_RES] );

	// セルデータ読み込み
	res_obj[CLACT_U_CELL_RES] = CLACT_U_ResManagerResAddArcKindCell_ArcHandle(
									res_man[CLACT_U_CELL_RES],
									ah,
									cel,
									FALSE,
									comm_res_cel,
									CLACT_U_CELL_RES,
									HEAPID_SUBLCD_MENU );

	// セルアニメデータ読み込み
	res_obj[CLACT_U_CELLANM_RES] = CLACT_U_ResManagerResAddArcKindCell_ArcHandle(
									res_man[CLACT_U_CELLANM_RES],
									ah,
									anm,
									FALSE,
									comm_res_anm,
									CLACT_U_CELLANM_RES,
									HEAPID_SUBLCD_MENU );
}

//--------------------------------------------------------------------------------------------
/**
 * セルアクターヘッダー作成
 *
 * @param	res_obj		リソースオブジェ
 * @param	res_man		リソースマネージャー
 * @param	head		ヘッダー作成先
 * @param	bg_pri		ＢＧとのプライオリティ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaHeaderMake(
				CLACT_U_RES_OBJ_PTR * res_obj,
				CLACT_U_RES_MANAGER_PTR * res_man,
				CLACT_HEADER * head,
				int bg_pri )
{
	CLACT_U_MakeHeader(
		head,
		CLACT_U_ResManagerGetResObjID( res_obj[CLACT_U_CHAR_RES] ),
		CLACT_U_ResManagerGetResObjID( res_obj[CLACT_U_PLTT_RES] ),
		CLACT_U_ResManagerGetResObjID( res_obj[CLACT_U_CELL_RES] ),
		CLACT_U_ResManagerGetResObjID( res_obj[CLACT_U_CELLANM_RES] ),
		CLACT_U_HEADER_DATA_NONE,
		CLACT_U_HEADER_DATA_NONE,
		0,
		bg_pri,
		res_man[CLACT_U_CHAR_RES],
		res_man[CLACT_U_PLTT_RES],
		res_man[CLACT_U_CELL_RES],
		res_man[CLACT_U_CELLANM_RES],
		NULL,
		NULL );
}

//--------------------------------------------------------------------------------------------
/**
 * セルアクター追加
 *
 * @param	wk			ダウジング画面ワーク
 * @param	objID		OBJ ID
 * @param	hed			ヘッダー
 * @param	prm			OBJ表示パラメータ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaAddCore( NUMSEL_WORK * wk, u32 objID, CLACT_HEADER * hed, const u8 * prm )
{
	CLACT_ADD add;

	add.ClActSet    = wk->claSet;
	add.ClActHeader = hed;

	add.mat.x       = (prm[0]<<FX32_SHIFT);
	add.mat.y       = (prm[1]<<FX32_SHIFT) + NS_SUB_ACTOR_DISTANCE;
	add.mat.z       = 0;

	add.sca.x       = FX32_ONE;
	add.sca.y       = FX32_ONE;
	add.sca.z       = FX32_ONE;

	add.rot         = 0;
	add.pri         = prm[2];
	add.DrawArea    = NNS_G2D_VRAM_TYPE_2DSUB;
	add.heap        = HEAPID_SUBLCD_MENU;

	wk->actWork[objID] = CLACT_Add( &add );

	CLACT_AnmChg( wk->actWork[objID], prm[3] );
}

// OBJデータ
static const u8 ObjParam[][4] =
{	// x, y, pri, anm
	{  32,  32, 0, 1 },	// カーソル
	{  48,  36, 0, 0 },	// バー
	{  40, 176, 1, 3 },	// もどる
	{ 128, 176, 1, 3 },	// けってい
	{ 216, 176, 1, 3 },	// やめる

	{  48,  24, 1, 1 },	// 数字
	{  80,  24, 1, 1 },	// 数字
	{ 112,  24, 1, 1 },	// 数字
	{ 144,  24, 1, 1 },	// 数字
	{ 176,  24, 1, 1 },	// 数字
	{ 208,  24, 1, 1 },	// 数字
};

//--------------------------------------------------------------------------------------------
/**
 * ＯＢＪを追加
 *
 * @param	wk		数値入力画面ワーク
 * @param	ah		アークハンドル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaAdd( NUMSEL_WORK * wk, ARCHANDLE * ah )
{
	CLACT_HEADER	hed;
	u32	i;

	ClaResLoadHandle(
		wk->resObj[NS_RES_MAN_BUTTON],
		wk->resMan,
		ah,
		NARC_btower_codein_code_obj_ncgr,
		NARC_btower_codein_code_obj_nclr,
		NARC_btower_codein_code_obj_ncer,
		NARC_btower_codein_code_obj_nanr,
		2,
		NS_RES_ID_BUTTON,
		NS_RES_ID_BUTTON,
		NS_RES_ID_BUTTON,
		NS_RES_ID_BUTTON );

	ClaHeaderMake( wk->resObj[NS_RES_MAN_BUTTON], wk->resMan, &hed, 1 );

	ClaAddCore( wk, NS_OBJ_CURSOR, &hed, ObjParam[NS_OBJ_CURSOR] );
	ClaAddCore( wk, NS_OBJ_NUM_BAR, &hed, ObjParam[NS_OBJ_NUM_BAR] );
	ClaAddCore( wk, NS_OBJ_RET_BUTTON, &hed, ObjParam[NS_OBJ_RET_BUTTON] );
	ClaAddCore( wk, NS_OBJ_ENTER_BUTTON, &hed, ObjParam[NS_OBJ_ENTER_BUTTON] );
	ClaAddCore( wk, NS_OBJ_CANCEL_BUTTON, &hed, ObjParam[NS_OBJ_CANCEL_BUTTON] );

	ClaResLoadHandle(
		wk->resObj[NS_RES_MAN_NUM],
		wk->resMan,
		ah,
		NARC_btower_codein_code_ncgr,
		NARC_btower_codein_code_nclr,
		NARC_btower_codein_code_ncer,
		NARC_btower_codein_code_nanr,
		2,
		NS_RES_ID_NUM,
		NS_RES_ID_NUM,
		NS_RES_ID_NUM,
		NS_RES_ID_NUM );

	ClaHeaderMake( wk->resObj[NS_RES_MAN_NUM], wk->resMan, &hed, 1 );

	ClaAddCore( wk, NS_OBJ_NUM0, &hed, ObjParam[NS_OBJ_NUM0] );
	ClaAddCore( wk, NS_OBJ_NUM1, &hed, ObjParam[NS_OBJ_NUM1] );
	ClaAddCore( wk, NS_OBJ_NUM2, &hed, ObjParam[NS_OBJ_NUM2] );
	ClaAddCore( wk, NS_OBJ_NUM3, &hed, ObjParam[NS_OBJ_NUM3] );
	ClaAddCore( wk, NS_OBJ_NUM4, &hed, ObjParam[NS_OBJ_NUM4] );
	ClaAddCore( wk, NS_OBJ_NUM5, &hed, ObjParam[NS_OBJ_NUM5] );

	for( i=0; i<DEFAULT_KETA; i++ ){
		if( i < wk->keta ){
			CLACT_SetDrawFlag( wk->actWork[NS_OBJ_NUM0+i], 1 );
		}else{
			CLACT_SetDrawFlag( wk->actWork[NS_OBJ_NUM0+i], 0 );
		}
	}
}

//--------------------------------------------------------------------------------------------
/**
 * ＯＢＪを削除
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaDel( NUMSEL_WORK * wk )
{
	u32	i;

	for( i=0; i<NS_OBJ_MAX; i++ ){
		CLACT_Delete( wk->actWork[i] );
	}

	CLACT_U_CharManagerDelete( wk->resObj[NS_RES_MAN_NUM][CLACT_U_CHAR_RES] );
	CLACT_U_PlttManagerDelete( wk->resObj[NS_RES_MAN_NUM][CLACT_U_PLTT_RES] );

	CLACT_U_CharManagerDelete( wk->resObj[NS_RES_MAN_BUTTON][CLACT_U_CHAR_RES] );
	CLACT_U_PlttManagerDelete( wk->resObj[NS_RES_MAN_BUTTON][CLACT_U_PLTT_RES] );
}

//--------------------------------------------------------------------------------------------
/**
 * ＯＢＪアニメメイン
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ClaAnmMain( NUMSEL_WORK * wk )
{
	u32	i;

	for( i=0; i<NS_OBJ_MAX; i++ ){
		CLACT_AnmFrameChg( wk->actWork[i], FX32_ONE );
	}
}





// 数字タッチテーブル：１桁
static const RECT_HIT_TBL NumRectHitTbl_1[] =
{
	{ 8, 39, 112, 143 },
	{ RECT_HIT_END, 0, 0, 0 }
};
// 数字タッチテーブル：２桁
static const RECT_HIT_TBL NumRectHitTbl_2[] =
{
	{ 8, 39,  96, 127 },
	{ 8, 39, 128, 159 },
	{ RECT_HIT_END, 0, 0, 0 }
};
// 数字タッチテーブル：３桁
static const RECT_HIT_TBL NumRectHitTbl_3[] =
{
	{ 8, 39,  80, 111 },
	{ 8, 39, 112, 143 },
	{ 8, 39, 144, 175 },
	{ RECT_HIT_END, 0, 0, 0 }
};
// 数字タッチテーブル：４桁
static const RECT_HIT_TBL NumRectHitTbl_4[] =
{
	{ 8, 39,  64,  95 },
	{ 8, 39,  96, 127 },
	{ 8, 39, 128, 159 },
	{ 8, 39, 160, 191 },
	{ RECT_HIT_END, 0, 0, 0 }
};
// 数字タッチテーブル：５桁
static const RECT_HIT_TBL NumRectHitTbl_5[] =
{
	{ 8, 39,  48,  79 },
	{ 8, 39,  80, 111 },
	{ 8, 39, 112, 143 },
	{ 8, 39, 144, 175 },
	{ 8, 39, 176, 207 },
	{ RECT_HIT_END, 0, 0, 0 }
};
// 数字タッチテーブル：６桁
static const RECT_HIT_TBL NumRectHitTbl_6[] =
{
	{ 8, 39,  32,  63 },
	{ 8, 39,  64,  95 },
	{ 8, 39,  96, 127 },
	{ 8, 39, 128, 159 },
	{ 8, 39, 160, 191 },
	{ 8, 39, 192, 224 },
	{ RECT_HIT_END, 0, 0, 0 }
};

// 数字タッチテーブル
static const RECT_HIT_TBL * const NumRectHitTbl[] = {
	NULL,
	NumRectHitTbl_1,
	NumRectHitTbl_2,
	NumRectHitTbl_3,
	NumRectHitTbl_4,
	NumRectHitTbl_5,
	NumRectHitTbl_6
};

static const u8 NumPosX_1 = 128;
static const u8 NumPosX_2[] = { 112, 144 };
static const u8 NumPosX_3[] = { 96, 128, 160 };
static const u8 NumPosX_4[] = { 80, 112, 144, 176 };
static const u8 NumPosX_5[] = { 64, 96, 128, 160, 192 };
static const u8 NumPosX_6[] = { 48, 80, 112, 144, 176, 208 };

// 数字表示Ｘ座標テーブル
static const u8 * const NumPosTbl[] = {
	NULL,
	&NumPosX_1,
	NumPosX_2,
	NumPosX_3,
	NumPosX_4,
	NumPosX_5,
	NumPosX_6,
};

// 固定タッチデータ
static const RECT_HIT_TBL FixRectHitTbl[] =
{
	{  56, 103,   8,  55 },		// 00: 0
	{  56, 103,  56, 103 },		// 01: 1
	{  56, 103, 104, 151 },		// 02: 2
	{  56, 103, 152, 199 },		// 03: 3
	{  56, 103, 200, 247 },		// 04: 4
	{ 104, 151,   8,  55 },		// 05: 5
	{ 104, 151,  56, 103 },		// 06: 6
	{ 104, 151, 104, 151 },		// 07: 7
	{ 104, 151, 152, 199 },		// 08: 8
	{ 104, 151, 200, 247 },		// 09: 9

	{ 160, 191,   0,  79 },		// 10: もどる
	{ 160, 191,  88, 167 },		// 11: けってい
	{ 160, 191, 176, 255 },		// 12: やめる

	{ RECT_HIT_END, 0, 0, 0 }
};
static const POINTER_WORK FixKeyTbl[] =
{
	{  32,  80, 0, 0,	0, 5, 4, 1 },		// 00: 0
	{  80,  80, 0, 0,	1, 6, 0, 2 },		// 01: 1
	{ 128,  80, 0, 0,	2, 7, 1, 3 },		// 02: 2
	{ 176,  80, 0, 0,	3, 8, 2, 4 },		// 03: 3
	{ 224,  80, 0, 0,	4, 9, 3, 0 },		// 04: 4
	{  32, 128, 0, 0,	0, CURSORMOVE_RETBIT|10, 9, 6 },	// 05: 5
	{  80, 128, 0, 0,	1, CURSORMOVE_RETBIT|10, 5, 7 },	// 06: 6
	{ 128, 128, 0, 0,	2, CURSORMOVE_RETBIT|11, 6, 8 },	// 07: 7
	{ 176, 128, 0, 0,	3, CURSORMOVE_RETBIT|12, 7, 9 },	// 08: 8
	{ 224, 128, 0, 0,	4, CURSORMOVE_RETBIT|12, 8, 5 },	// 09: 9

	{  40, 176, 0, 0,	CURSORMOVE_RETBIT|5, 10, 12, 11 },	// 10: もどる
	{ 128, 176, 0, 0,	CURSORMOVE_RETBIT|7, 11, 10, 12 },	// 11: けってい
	{ 216, 176, 0, 0,	CURSORMOVE_RETBIT|9, 12, 11, 10 },	// 12: やめる
};
static const CURSORMOVE_CALLBACK CursorMoveCallBack = {
	CursorMoveCallBack_On,
	CursorMoveCallBack_On,
	CursorMoveCallBack_Move,
	CursorMoveCallBack_Move
};

// ボタンＩＤ
enum {
	BUTTON_ID_NUM0 = 0,
	BUTTON_ID_NUM1,
	BUTTON_ID_NUM2,
	BUTTON_ID_NUM3,
	BUTTON_ID_NUM4,
	BUTTON_ID_NUM5,
	BUTTON_ID_NUM6,
	BUTTON_ID_NUM7,
	BUTTON_ID_NUM8,
	BUTTON_ID_NUM9,
	BUTTON_ID_RET,
	BUTTON_ID_ENTER,
	BUTTON_ID_CANCEL,
};

static void InputNumCursorPut( NUMSEL_WORK * wk );

//--------------------------------------------------------------------------------------------
/**
 * カーソルＯＢＪ配置
 *
 * @param	wk		数値入力画面ワーク
 * @param	pos		位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorObjPut( NUMSEL_WORK * wk, u32 pos )
{
	const POINTER_WORK * pw;
	VecFx32	vec;

	pw = CURSORMOVE_PointerWorkGet( wk->cmwk, pos );

	vec.x = pw->px * FX32_ONE;
	vec.y = pw->py * FX32_ONE + NS_SUB_ACTOR_DISTANCE;

	CLACT_SetMatrix( wk->actWork[NS_OBJ_CURSOR], &vec );

	if( pos >= BUTTON_ID_NUM0 && pos <= BUTTON_ID_NUM9 ){
		CLACT_AnmChg( wk->actWork[NS_OBJ_CURSOR], 1 );
	}else{
		CLACT_AnmChg( wk->actWork[NS_OBJ_CURSOR], 2 );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動ワーク初期化
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveInit( NUMSEL_WORK * wk )
{
	wk->cmwk = CURSORMOVE_Create(
					FixRectHitTbl,
					FixKeyTbl,
					&CursorMoveCallBack,
					wk,
					TRUE,
					0,
					HEAPID_SUBLCD_MENU );

	CursorObjPut( wk, 0 );
	InputNumCursorPut( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動ワーク削除
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveExit( NUMSEL_WORK * wk )
{
	CURSORMOVE_Exit( wk->cmwk );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック関数：ダミー
 *
 * @param	work		数値入力画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_On( void * work, int now_pos, int old_pos )
{
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック関数：カーソル移動（タッチも）
 *
 * @param	work		数値入力画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos )
{
	NUMSEL_WORK * wk = work;

	CursorObjPut( wk, now_pos );
}

// 桁カーソル表示データ
#define	NUM_CURSOR_PY	( 36 )
#define	NUM_PY			( 24 )

//--------------------------------------------------------------------------------------------
/**
 * 桁カーソル配置
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void InputNumCursorPut( NUMSEL_WORK * wk )
{
	const u8 * xtbl;
	VecFx32	vec;

	xtbl  = NumPosTbl[wk->keta];
	vec.x = xtbl[wk->input_pos] * FX32_ONE;
	vec.y = NUM_CURSOR_PY * FX32_ONE + NS_SUB_ACTOR_DISTANCE;

	CLACT_SetMatrix( wk->actWork[NS_OBJ_NUM_BAR], &vec );
}

//--------------------------------------------------------------------------------------------
/**
 * 数値配置
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void InputNumPut( NUMSEL_WORK * wk )
{
	const u8 * xtbl;
	VecFx32	vec;
	u32	i;

	xtbl  = NumPosTbl[wk->keta];
	vec.y = NUM_PY * FX32_ONE + NS_SUB_ACTOR_DISTANCE;

	for( i=0; i<wk->keta; i++ ){
		vec.x = xtbl[i] * FX32_ONE;
		CLACT_SetMatrix( wk->actWork[NS_OBJ_NUM0+i], &vec );
	}
}


static BOOL InputPosMove( NUMSEL_WORK * wk, s32 mv );
static void InputMain( NUMSEL_WORK * wk, u32 num );
static BOOL ButtonAnmMain( NUMSEL_WORK * wk );
static void ObjButtonAnmSet( NUMSEL_WORK * wk, u8 id, u8 anm1, u8 anm2, u16 next );
static void BgButtonAnmSet( NUMSEL_WORK * wk, u8 px, u8 py, u16 next );
static void RetNumSet( NUMSEL_WORK * wk );

//--------------------------------------------------------------------------------------------
/**
 * メインタスク
 *
 * @param	tcb		TCB_PTR
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MainTask( TCB_PTR tcb, void * work )
{
	NUMSEL_WORK * wk;
	u32	ret;

	wk = work;

	switch( wk->main_seq ){
	case MAINSEQ_MAIN:
		ret = GF_TP_RectHitTrg( NumRectHitTbl[wk->keta] );
		if( ret != RECT_HIT_NONE ){
			wk->input_pos = ret;
			InputNumCursorPut( wk );
			ObjButtonAnmSet(
				wk, NS_OBJ_NUM0+ret,
				12+wk->input_num[ wk->input_pos ],
				1+wk->input_num[ wk->input_pos ],
				MAINSEQ_MAIN );
			Snd_SePlay( SE_NUMSEL_POS_SELECT );
		}else if( sys.trg & PAD_BUTTON_START ){
			CURSORMOVE_PosSet( wk->cmwk, BUTTON_ID_ENTER );
			CursorObjPut( wk, BUTTON_ID_ENTER );
			Snd_SePlay( SE_NUMSEL_INPUT );
		}else if( sys.trg & PAD_BUTTON_B ){
			if( InputPosMove( wk, -1 ) == TRUE ){
				Snd_SePlay( SE_NUMSEL_POS_RETURN );
			}
		}else{
			ret = CURSORMOVE_MainCont( wk->cmwk );

			switch( ret ){
			case BUTTON_ID_NUM0:
			case BUTTON_ID_NUM1:
			case BUTTON_ID_NUM2:
			case BUTTON_ID_NUM3:
			case BUTTON_ID_NUM4:
			case BUTTON_ID_NUM5:
			case BUTTON_ID_NUM6:
			case BUTTON_ID_NUM7:
			case BUTTON_ID_NUM8:
			case BUTTON_ID_NUM9:
				InputMain( wk, ret );
				InputPosMove( wk, 1 );
				BgButtonAnmSet( wk, (ret%5)*6+1, (ret/5)*6+7, MAINSEQ_MAIN );
				Snd_SePlay( SE_NUMSEL_INPUT );
				break;

			case BUTTON_ID_RET:
				ObjButtonAnmSet( wk, NS_OBJ_RET_BUTTON, 4, 3, MAINSEQ_MAIN );
				InputPosMove( wk, -1 );
				Snd_SePlay( SE_NUMSEL_POS_RETURN );
				break;

			case BUTTON_ID_ENTER:
				RetNumSet( wk );
				if( wk->num > wk->prm->max ){
					ObjButtonAnmSet( wk, NS_OBJ_ENTER_BUTTON, 4, 3, MAINSEQ_MAIN );
					Snd_SePlay( SE_NUMSEL_ERROR );
				}else{
					wk->prm->num = wk->num;
					ObjButtonAnmSet( wk, NS_OBJ_ENTER_BUTTON, 4, 3, MAINSEQ_END );
//					ObjButtonAnmSet( wk, NS_OBJ_ENTER_BUTTON, 4, 3, MAINSEQ_MAIN );
					Snd_SePlay( SE_NUMSEL_ENTER );
				}
				break;

			case BUTTON_ID_CANCEL:
				wk->prm->num = NUMSEL_SUBLCD_RET_CANCEL;
				ObjButtonAnmSet( wk, NS_OBJ_CANCEL_BUTTON, 4, 3, MAINSEQ_END );
//				ObjButtonAnmSet( wk, NS_OBJ_CANCEL_BUTTON, 4, 3, MAINSEQ_MAIN );
				Snd_SePlay( SE_NUMSEL_CANCEL );
				break;
			}
		}

		break;

	case MAINSEQ_BUTTON_ANM:
		if( ButtonAnmMain( wk ) == FALSE ){
			wk->main_seq = wk->next_seq;
		}
		break;

	case MAINSEQ_END:
		break;
	}

	ClaAnmMain( wk );
	CLACT_Draw( wk->claSet );
}

//--------------------------------------------------------------------------------------------
/**
 * 桁変更
 *
 * @param	wk		数値入力画面ワーク
 * @param	mv		移動方向
 *
 * @retval	"TRUE = 変更した"
 * @retval	"FALSE = それ以外"
 */
//--------------------------------------------------------------------------------------------
static BOOL InputPosMove( NUMSEL_WORK * wk, s32 mv )
{
	s32	tmp;

	tmp = wk->input_pos;

	wk->input_pos += mv;

	if( wk->input_pos < 0 ){
		wk->input_pos = 0;
	}else if( wk->input_pos >= wk->keta ){
		wk->input_pos = wk->keta - 1;
	}

	if( wk->input_pos == tmp ){
		return FALSE;
	}

	InputNumCursorPut( wk );
	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * 入力メイン
 *
 * @param	wk		数値入力画面ワーク
 * @param	num		値
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void InputMain( NUMSEL_WORK * wk, u32 num )
{
	wk->input_num[wk->input_pos] = num;
	CLACT_AnmChg( wk->actWork[NS_OBJ_NUM0+wk->input_pos], num+1 );
}


//--------------------------------------------------------------------------------------------
/**
 * ボタン切り替え
 *
 * @param	wk		数値入力画面ワーク
 * @param	pal		パレット
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ButtonAnmCore( NUMSEL_WORK * wk, u8 pal )
{
	if( wk->bawk.btn_mode == BTN_ANM_MODE_OBJ ){
		CLACT_AnmChg( wk->actWork[wk->bawk.btn_id], pal );
	}else{
		GF_BGL_ScrPalChange(
			wk->bgl, wk->bawk.btn_id,
			wk->bawk.btn_px, wk->bawk.btn_py, wk->bawk.btn_sx, wk->bawk.btn_sy, pal );
		GF_BGL_LoadScreenV_Req( wk->bgl, wk->bawk.btn_id );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * ボタンアニメ処理
 *
 * @param	wk		数値入力画面ワーク
 *
 * @retval	"TRUE = アニメ中"
 * @retval	"FALSE = それ以外"
 */
//--------------------------------------------------------------------------------------------
static BOOL ButtonAnmMain( NUMSEL_WORK * wk )
{
	BUTTON_ANM_WORK * bawk = &wk->bawk;

	switch( bawk->btn_seq ){
	case 0:
		ButtonAnmCore( wk, bawk->btn_pal1 );
		bawk->btn_seq++;
		break;

	case 1:
		bawk->btn_cnt++;
		if( bawk->btn_cnt != 4 ){ break; }
		ButtonAnmCore( wk, bawk->btn_pal2 );
		bawk->btn_cnt = 0;
		bawk->btn_seq++;
		break;

	case 2:
		bawk->btn_cnt++;
		if( bawk->btn_cnt == 2 ){
			return FALSE;
		}
	}

	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * ボタンアニメ設定（ＯＢＪ）
 *
 * @param	wk		数値入力画面ワーク
 * @param	id		OBJ ID
 * @param	anm1	アニメ１
 * @param	anm2	アニメ２
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjButtonAnmSet( NUMSEL_WORK * wk, u8 id, u8 anm1, u8 anm2, u16 next )
{
	wk->bawk.btn_mode = BTN_ANM_MODE_OBJ;
	wk->bawk.btn_cnt  = 0;
	wk->bawk.btn_seq  = 0;
	wk->bawk.btn_id   = id;
	wk->bawk.btn_pal1 = anm1;
	wk->bawk.btn_pal2 = anm2;

	wk->next_seq = next;
	wk->main_seq = MAINSEQ_BUTTON_ANM;
}

//--------------------------------------------------------------------------------------------
/**
 * ボタンアニメ設定（ＢＧ）
 *
 * @param	wk		数値入力画面ワーク
 * @param	px		Ｘ座標
 * @param	py		Ｙ座標
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgButtonAnmSet( NUMSEL_WORK * wk, u8 px, u8 py, u16 next )
{
	wk->bawk.btn_mode = BTN_ANM_MODE_BG;
	wk->bawk.btn_cnt  = 0;
	wk->bawk.btn_seq  = 0;
	wk->bawk.btn_id   = GF_BGL_FRAME1_S;
	wk->bawk.btn_pal1 = 1;
	wk->bawk.btn_pal2 = 0;

	wk->bawk.btn_px = px;
	wk->bawk.btn_py = py;
	wk->bawk.btn_sx = 6;
	wk->bawk.btn_sy = 6;

	wk->next_seq = next;
	wk->main_seq = MAINSEQ_BUTTON_ANM;
}

//--------------------------------------------------------------------------------------------
/**
 * 入力された各桁の数値を１つの数値にする
 *
 * @param	wk		数値入力画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void RetNumSet( NUMSEL_WORK * wk )
{
	u32	tmp;
	u32	i;

	tmp = 0;
	for( i=0; i<wk->keta; i++ ){
		tmp *= 10;
		tmp += wk->input_num[i];
	}
	wk->num = tmp;
}